package com.example.doc.service;

import com.example.doc.mapper.RoleMapper;
import com.example.doc.model.Role;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RoleService {

    @Resource
    RoleMapper roleMapper;

    public Integer saveRole(Role role){
        if (!role.getName().startsWith("ROLE_")) {
            role.setName("ROLE_" + role.getName());
        }
        return roleMapper.addRole(role);
    }

    public Integer deleteRole(Long id){
        return roleMapper.deleteRole(id);
    }

    public List<Role> getAllRoles(){
        return roleMapper.getAllRoles();
    }



}
